// 显示和隐藏闪存消息
document.addEventListener("DOMContentLoaded", () => {
    const alerts = document.querySelectorAll(".alert");
    alerts.forEach(alert => {
        setTimeout(() => {
            alert.style.display = "none";
        }, 3000); // 消息显示 3 秒后自动消失
    });
});

// 确认删除文章
const deleteButtons = document.querySelectorAll("form[action*='delete'] button");
deleteButtons.forEach(button => {
    button.addEventListener("click", (event) => {
        const confirmation = confirm("Are you sure you want to delete this post?");
        if (!confirmation) {
            event.preventDefault();
        }
    });
});
